<script setup lang="ts">
// 产品数据
const products = [
  {
    id: 1,
    name: '智能数据分析平台',
    category: '数据分析',
    description: '基于人工智能的数据分析平台，帮助企业快速处理和分析海量数据，发现业务洞察，支持数据驱动决策。',
    features: [
      '实时数据处理',
      '智能预测分析',
      '可视化报表生成',
      '多维度数据分析'
    ],
    price: '¥29,800/年',
    image: 'https://images.unsplash.com/photo-1551288049-bebda4e38f71?auto=format&fit=crop&q=80'
  },
  {
    id: 2,
    name: '企业资源管理系统',
    category: '企业管理',
    description: '一体化企业资源管理解决方案，整合财务、人力资源、采购等核心业务流程，提升企业运营效率。',
    features: [
      '模块化设计',
      '流程自动化',
      '多部门协作',
      '可定制化配置'
    ],
    price: '¥49,800/年',
    image: 'https://images.unsplash.com/photo-1600880292089-90a7e086ee0c?auto=format&fit=crop&q=80'
  },
  {
    id: 3,
    name: '客户关系管理系统',
    category: '客户管理',
    description: '全面的客户关系管理系统，帮助企业有效管理客户数据，优化销售流程，提升客户满意度和忠诚度。',
    features: [
      '客户360°视图',
      '销售线索管理',
      '客户互动跟踪',
      '智能营销自动化'
    ],
    price: '¥19,800/年',
    image: 'https://images.unsplash.com/photo-1552664730-d307ca884978?auto=format&fit=crop&q=80'
  },
  {
    id: 4,
    name: '云计算服务平台',
    category: '云计算',
    description: '弹性可扩展的云计算服务平台，提供安全、稳定、高效的计算、存储和网络资源，支持企业数字化转型。',
    features: [
      '按需资源分配',
      '高可用架构',
      '数据安全保障',
      '全球部署支持'
    ],
    price: '按需计费',
    image: 'https://images.unsplash.com/photo-1581091226825-a6a2a5aee158?auto=format&fit=crop&q=80'
  },
  {
    id: 5,
    name: '人工智能开发平台',
    category: 'AI技术',
    description: '面向开发者的人工智能开发平台，提供丰富的AI模型和工具，帮助企业快速构建和部署AI应用。',
    features: [
      '预训练模型库',
      '可视化建模工具',
      '模型训练与部署',
      'API服务集成'
    ],
    price: '¥39,800/年',
    image: 'https://images.unsplash.com/photo-1677442136072-70e50c180a25?auto=format&fit=crop&q=80'
  },
  {
    id: 6,
    name: '物联网管理平台',
    category: '物联网',
    description: '物联网设备管理和数据分析平台，实现设备连接、监控和智能分析，助力企业构建智能物联生态。',
    features: [
      '设备接入管理',
      '实时监控预警',
      '数据分析挖掘',
      '远程控制功能'
    ],
    price: '¥24,800/年',
    image: 'https://images.unsplash.com/photo-1550751827-4bd374c3f58b?auto=format&fit=crop&q=80'
  }
]

// 产品分类
const categories = ['全部', '数据分析', '企业管理', '客户管理', '云计算', 'AI技术', '物联网']

// 当前选中的分类
const selectedCategory = ref('全部')

// 过滤产品
const filteredProducts = computed(() => {
  if (selectedCategory.value === '全部') {
    return products
  }
  return products.filter(product => product.category === selectedCategory.value)
})

// 选中产品（用于详情展示）
const selectedProduct = ref(null)

// 显示产品详情
const showProductDetails = (product) => {
  selectedProduct.value = product
}

// 关闭产品详情
const closeProductDetails = () => {
  selectedProduct.value = null
}
</script>

<template>
  <div class="products-page">
    <!-- 页面标题 -->
    <section class="page-header">
      <h1>产品中心</h1>
      <p>探索我们的创新产品和解决方案</p>
    </section>

    <!-- 产品分类 -->
    <section class="categories-section">
      <div class="categories-container">
        <button
          v-for="category in categories"
          :key="category"
          class="category-btn"
          :class="{ active: selectedCategory === category }"
          @click="selectedCategory = category"
        >
          {{ category }}
        </button>
      </div>
    </section>

    <!-- 产品列表 -->
    <section class="products-section">
      <div class="products-grid">
        <div
          v-for="product in filteredProducts"
          :key="product.id"
          class="card product-card"
          @click="showProductDetails(product)"
        >
          <div class="product-image">
            <img :src="product.image" :alt="product.name">
            <div class="product-category">{{ product.category }}</div>
          </div>
          <div class="product-info">
            <h3>{{ product.name }}</h3>
            <p class="product-description">{{ product.description }}</p>
            <div class="product-price">{{ product.price }}</div>
            <button class="view-details-btn">查看详情</button>
          </div>
        </div>
      </div>

      <!-- 无产品提示 -->
      <div v-if="filteredProducts.length === 0" class="no-products">
        <p>暂无相关产品</p>
      </div>
    </section>

    <!-- 产品详情模态框 -->
    <Transition name="modal">
      <div v-if="selectedProduct" class="modal-overlay" @click.self="closeProductDetails">
        <div class="modal-content">
          <button class="close-btn" @click="closeProductDetails">×</button>
          <div class="product-details">
            <div class="details-image">
              <img :src="selectedProduct.image" :alt="selectedProduct.name">
            </div>
            <div class="details-info">
              <div class="product-category">{{ selectedProduct.category }}</div>
              <h2>{{ selectedProduct.name }}</h2>
              <div class="product-price">{{ selectedProduct.price }}</div>
              <p class="product-description">{{ selectedProduct.description }}</p>
              
              <div class="product-features">
                <h3>核心功能</h3>
                <ul>
                  <li v-for="(feature, index) in selectedProduct.features" :key="index">
                    {{ feature }}
                  </li>
                </ul>
              </div>
              
              <div class="action-buttons">
                <button class="contact-btn">联系我们</button>
                <button class="demo-btn">申请演示</button>
              </div>
            </div>
          </div>
        </div>
      </div>
    </Transition>
  </div>
</template>

<style scoped>
.products-page {
  width: 100%;
}

/* 页面标题 */
.page-header {
  text-align: center;
  margin-bottom: 60px;
  padding: 60px 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 12px;
  margin-top: 30px;
}

.page-header h1 {
  font-size: 48px;
  font-weight: 700;
  margin-bottom: 15px;
}

.page-header p {
  font-size: 18px;
  opacity: 0.9;
}

/* 产品分类 */
.categories-section {
  margin-bottom: 50px;
}

.categories-container {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  justify-content: center;
}

.category-btn {
  padding: 10px 20px;
  border: 2px solid #e0e0e0;
  background: white;
  border-radius: 25px;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
  color: #333;
}

.category-btn:hover {
  border-color: #667eea;
  color: #667eea;
  transform: translateY(-2px);
}

.category-btn.active {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-color: transparent;
}

/* 产品列表 */
.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 30px;
}

.product-card {
  cursor: pointer;
  transition: all 0.3s ease;
  overflow: hidden;
}

.product-card:hover {
  transform: translateY(-10px);
  box-shadow: 0 20px 30px rgba(0, 0, 0, 0.1);
}

.product-image {
  position: relative;
  height: 220px;
  overflow: hidden;
}

.product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.product-card:hover .product-image img {
  transform: scale(1.05);
}

.product-category {
  position: absolute;
  top: 15px;
  left: 15px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 5px 15px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 500;
}

.product-info {
  padding: 25px;
}

.product-info h3 {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 15px;
  color: #333;
  line-height: 1.3;
}

.product-description {
  color: #666;
  font-size: 16px;
  line-height: 1.6;
  margin-bottom: 20px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-price {
  font-size: 20px;
  font-weight: 700;
  color: #667eea;
  margin-bottom: 20px;
}

.view-details-btn {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.view-details-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

/* 无产品提示 */
.no-products {
  text-align: center;
  padding: 60px 0;
  color: #666;
  font-size: 18px;
}

/* 产品详情模态框 */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-content {
  background: white;
  border-radius: 16px;
  max-width: 900px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.close-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: #f5f5f5;
  font-size: 24px;
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 10;
}

.close-btn:hover {
  background: #e0e0e0;
  transform: scale(1.1);
}

.product-details {
  display: flex;
  flex-wrap: wrap;
}

.details-image {
  flex: 1;
  min-width: 300px;
  max-width: 100%;
  overflow: hidden;
}

.details-image img {
  width: 100%;
  height: auto;
  display: block;
}

.details-info {
  flex: 1;
  min-width: 300px;
  padding: 40px;
}

.details-info h2 {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 20px;
  color: #333;
}

.details-info .product-description {
  -webkit-line-clamp: unset;
  margin-bottom: 30px;
}

.product-features {
  margin-bottom: 30px;
}

.product-features h3 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 15px;
  color: #333;
}

.product-features ul {
  list-style: none;
  padding: 0;
}

.product-features li {
  position: relative;
  padding-left: 30px;
  margin-bottom: 12px;
  color: #666;
  line-height: 1.6;
}

.product-features li::before {
  content: '✓';
  position: absolute;
  left: 0;
  color: #667eea;
  font-weight: bold;
  font-size: 18px;
}

.action-buttons {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
}

.contact-btn, .demo-btn {
  flex: 1;
  min-width: 150px;
  padding: 15px 30px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.contact-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.contact-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 10px 20px rgba(102, 126, 234, 0.4);
}

.demo-btn {
  background: white;
  color: #667eea;
  border: 2px solid #667eea;
}

.demo-btn:hover {
  background: #667eea;
  color: white;
  transform: translateY(-3px);
}

/* 模态框动画 */
.modal-enter-active,
.modal-leave-active {
  transition: opacity 0.3s ease;
}

.modal-enter-from,
.modal-leave-to {
  opacity: 0;
}

.modal-enter-active .modal-content,
.modal-leave-active .modal-content {
  transition: transform 0.3s ease;
}

.modal-enter-from .modal-content {
  transform: scale(0.9);
}

.modal-leave-to .modal-content {
  transform: scale(0.9);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .page-header {
    padding: 40px 0;
  }
  
  .page-header h1 {
    font-size: 36px;
  }
  
  .categories-container {
    justify-content: flex-start;
  }
  
  .category-btn {
    font-size: 14px;
    padding: 8px 16px;
  }
  
  .products-grid {
    grid-template-columns: 1fr;
  }
  
  .product-image {
    height: 200px;
  }
  
  .details-info {
    padding: 30px 20px;
  }
  
  .details-info h2 {
    font-size: 28px;
  }
  
  .action-buttons {
    flex-direction: column;
  }
  
  .contact-btn, .demo-btn {
    min-width: unset;
  }
}
</style>